package com.regvision.contacts.main;

import com.regvision.contacts.R;
import com.regvision.contacts.ui.BaseActivity;
import com.regvision.contacts.ui.MainActivity;
import com.regvision.contacts.utils.SharedPrefUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class InitActivity extends Activity implements OnClickListener {

	private EditText editUserName;
	private String userName;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_init);
		
		editUserName = (EditText) findViewById(R.id.etUserName);
		Button btnNext = (Button) findViewById(R.id.btnNext);
		btnNext.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
			case R.id.btnNext: {
				userName = editUserName.getText().toString();
				if (userName != null && !TextUtils.isEmpty(userName)) {
					finish();
					SharedPrefUtil.putString(this, "username", userName);
					Intent intent = new Intent(this, MainActivity.class);
					startActivity(intent);
				} else {
					Toast.makeText(this, "请输入您的用户名", Toast.LENGTH_SHORT).show();
				}
				
				break;
			}
			default:
				break;
			}
	}
	
}
